package db_neo4j;

import org.neo4j.graphdb.Node;
import org.neo4j.cypher.javacompat.*;
import org.neo4j.kernel.AbstractGraphDatabase;
import org.neo4j.kernel.EmbeddedGraphDatabase;

import java.util.Iterator;
import java.util.List;

import static org.neo4j.helpers.collection.IteratorUtil.asIterable;

public class Query_DB
{
    AbstractGraphDatabase db;
    String resultString;
    String columnsString;
    Node resultNode;
    
    public Query_DB(EmbeddedGraphDatabase db_in){
    	db = db_in;
    	this.run();
    }

    void run()
    {
        // START SNIPPET: execute
        ExecutionEngine engine = new ExecutionEngine( db );
        ExecutionResult result;
        for(int i = 0; i <100; i++){
        	result = engine.execute( "start n=node("+i+") where 1=1 return n" );
            System.out.println( result );
        }
        
        // END SNIPPET: execute
        // START SNIPPET: columns
        //List<String> columns = result.columns();
        //System.out.println( columns );
        // END SNIPPET: columns
        // START SNIPPET: items
//        Iterator<Node> n_column = result.columnAs( "n" );
//        for ( Node node : asIterable( n_column ) )
//        {
//            //System.out.println( node );
//            // END SNIPPET: items
//            resultNode = node;
//            // START SNIPPET: items
//        }
        // END SNIPPET: items
//        resultString = result.toString();
//        columnsString = columns.toString();
    }
}
